package neuralNetwork;

import java.util.List;

import neuralModel.neuron.INeuron;

public class NeuralNetworkUtils
{
	private NeuralNetworkUtils()
	{
	}

	public static void FullyConnectNetworkLayers(INeuralNetwork neuralNetwork, double intialWeight)
	{
		int totalLayers = neuralNetwork.getLayerCount();
		for (int i = 0; i < totalLayers - 1; i++)
		{
			FullyConnectNetworkLayers(neuralNetwork, i, i + 1, intialWeight);
		}
	}

	public static void FullyConnectNetworkLayers(INeuralNetwork neuralNetwork, int sourceLayerIndex,
	    int targetLayerIndex, double intialWeight)
	{
		if (neuralNetwork != null)
		{
			if (sourceLayerIndex < neuralNetwork.getLayerCount()
			    && targetLayerIndex < neuralNetwork.getLayerCount())
			{
				List<INeuron> sourceLayer = neuralNetwork.getLayer(sourceLayerIndex);
				List<INeuron> targetLayer = neuralNetwork.getLayer(targetLayerIndex);

				for (INeuron source : sourceLayer)
				{
					for (INeuron target : targetLayer)
					{
						neuralNetwork.connectNeurons(source, target, intialWeight);
					}
				}
			}
			else
			{
				throw new IllegalArgumentException("Invalid Network Layer Specified");
			}
		}
		else
		{
			throw new IllegalArgumentException("Null Network Specified");
		}

	}
}
